<template>
    <div class="module-card">
        <div class="module-header">
            <h2 class="module-title">数据备份</h2>
            <button class="px-3 py-1 text-sm bg-primary text-white rounded hover:bg-primary/90 transition-colors"
                @click="createBackup">立即备份</button>
        </div>
        <div class="p-4">
            <div class="flex items-center justify-between mb-4 pb-4 border-b border-gray-100">
                <div>
                    <div class="text-sm text-gray-500">上次备份</div>
                    <div class="font-medium mt-1">{{ lastBackupTime }}</div>
                </div>
                <div>
                    <div class="text-sm text-gray-500">备份状态</div>
                    <div class="font-medium mt-1" :class="backupStatusClass">{{ backupStatusText }}</div>
                </div>
                <div>
                    <div class="text-sm text-gray-500">备份大小</div>
                    <div class="font-medium mt-1">{{ backupSize }}</div>
                </div>
            </div>

            <div class="space-y-3">
                <div class="flex items-center justify-between p-2 hover:bg-gray-50 rounded-lg transition-colors">
                    <div class="flex items-center">
                        <div class="w-8 h-8 rounded bg-primary/10 flex items-center justify-center text-primary mr-3">
                            <i class="fa fa-database"></i>
                        </div>
                        <div>
                            <div class="text-sm font-medium">全量备份</div>
                            <div class="text-xs text-gray-500">每日凌晨2点自动执行</div>
                        </div>
                    </div>
                    <div class="text-xs px-2 py-0.5 bg-success/10 text-success">已启用</div>
                </div>

                <div class="flex items-center justify-between p-2 hover:bg-gray-50 rounded-lg transition-colors">
                    <div class="flex items-center">
                        <div class="w-8 h-8 rounded bg-info/10 flex items-center justify-center text-info mr-3">
                            <i class="fa fa-file-text-o"></i>
                        </div>
                        <div>
                            <div class="text-sm font-medium">增量备份</div>
                            <div class="text-xs text-gray-500">每6小时执行一次</div>
                        </div>
                    </div>
                    <div class="text-xs px-2 py-0.5 bg-success/10 text-success">已启用</div>
                </div>

                <div class="flex items-center justify-between p-2 hover:bg-gray-50 rounded-lg transition-colors">
                    <div class="flex items-center">
                        <div class="w-8 h-8 rounded bg-warning/10 flex items-center justify-center text-warning mr-3">
                            <i class="fa fa-cloud-upload"></i>
                        </div>
                        <div>
                            <div class="text-sm font-medium">云端备份</div>
                            <div class="text-xs text-gray-500">每周日同步至云端</div>
                        </div>
                    </div>
                    <div class="text-xs px-2 py-0.5 bg-gray-100 text-gray-500">已禁用</div>
                </div>
            </div>

            <div class="mt-4 pt-4 border-t border-gray-100">
                <button class="text-primary text-sm hover:underline" @click="viewBackupHistory">查看备份历史</button>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'DataBackupStatus',
    data() {
        return {
            lastBackupTime: '2023-10-14 02:00:15',
            backupStatusText: '正常',
            backupStatusClass: 'text-success',
            backupSize: '12.8 GB'
        };
    },
    methods: {
        createBackup() {
            // 执行备份逻辑
            this.$emit('create-backup');
        },
        viewBackupHistory() {
            // 查看备份历史逻辑
            this.$emit('view-backup-history');
        }
    }
}
</script>